@echo off
chcp 65001 >nul
cd /d "%~dp0"

echo ========================================
echo    Installing Floating Overlay
echo ========================================
echo.

echo [1/3] Checking Node.js...
node --version >nul 2>&1
if %errorLevel% neq 0 (
    echo [ERROR] Node.js not found!
    echo [TIPS] Please install Node.js first from: https://nodejs.org/
    pause
    exit /b 1
) else (
    for /f "tokens=*" %%i in ('node --version') do (
        echo [SUCCESS] Node.js: %%i
    )
)

echo [2/3] Installing dependencies...
echo [INFO] This may take a few minutes...

npm install
if %errorLevel% neq 0 (
    echo [ERROR] Failed to install dependencies!
    echo [TIPS] Try the following:
    echo   1. Check network connection
    echo   2. Run: npm cache clean --force
    echo   3. Try again
    pause
    exit /b 1
) else (
    echo [SUCCESS] Dependencies installed successfully!
)

echo [3/3] Checking installation...
if exist "node_modules\electron" (
    echo [SUCCESS] Electron found!
) else (
    echo [WARNING] Electron may not be installed correctly
)

echo.
echo ========================================
echo     Installation Completed!
echo ========================================
echo.
echo [SUCCESS] Floating overlay is ready!
echo [NEXT STEP] Run start_overlay.bat to launch the overlay
echo.
echo Press any key to exit...
pause >nul
